// dnSpy decompiler from Assembly-CSharp.dll class: GUIFPSDisplay
using System;
using UnityEngine;
using UnityEngine.UI;

[RequireComponent(typeof(Text))]
public class GUIFPSDisplay : CheckedMonoBehaviour
{
	private void Start()
	{
		if (!base.GetComponent<Text>())
		{
			UnityEngine.Debug.LogError("UtilityFramesPerSecond needs a GUIText component!");
			base.enabled = false;
			return;
		}
		this.timeleft = this.updateInterval;
		if (GameVersion.RELEASE)
		{
			base.gameObject.SetActive(false);
		}
	}

	private void Update()
	{
		this.timeleft -= Time.deltaTime;
		this.accum += Time.timeScale / Time.deltaTime;
		this.frames++;
		if ((double)this.timeleft <= 0.0)
		{
			float num = this.accum / (float)this.frames;
			string text = string.Format("{0:F2} FPS", num);
			base.GetComponent<Text>().text = text;
			if (num >= 45f)
			{
				base.GetComponent<Text>().material.color = Color.cyan;
			}
			else if (num >= 30f)
			{
				base.GetComponent<Text>().material.color = Color.green;
			}
			else if (num >= 20f)
			{
				base.GetComponent<Text>().material.color = Color.yellow;
			}
			else if (num >= 10f)
			{
				base.GetComponent<Text>().material.color = Color.red;
			}
			else
			{
				base.GetComponent<Text>().material.color = Color.magenta;
			}
			this.timeleft = this.updateInterval;
			this.accum = 0f;
			this.frames = 0;
		}
	}

	public float updateInterval = 0.5f;

	private float accum;

	private int frames;

	private float timeleft;
}
